<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="com.swim.entity.SkillRequest"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>SWIM</title>
<link href='http://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'/>
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />
<script type='text/javascript'>
	
		function checkNotEmpty(description,name,id){

			if(description.value == ""){
				alert("You have to describe the new skill!");
				
				description.focus();
			} else if(name.value == "") {
				alert("You have to give the skill a name!");
				
				name.focus();
			} else {		
				var form = document.createElement("form");
			    form.setAttribute("method", "post");
			    form.setAttribute("action", "newskill.jsp");

			    var hiddenField = document.createElement("input");
			    hiddenField.setAttribute("type", "hidden");
	            hiddenField.setAttribute("name", "desc");
	            hiddenField.setAttribute("value", description.value);
			    form.appendChild(hiddenField);
			    
			    hiddenField = document.createElement("input");
			    hiddenField.setAttribute("type", "hidden");
	            hiddenField.setAttribute("name", "name");
	            hiddenField.setAttribute("value", name.value);
			    form.appendChild(hiddenField);

			    if(id != ""){
				    hiddenField = document.createElement("input");
				    hiddenField.setAttribute("type", "hidden");
		            hiddenField.setAttribute("name", "id");
		            hiddenField.setAttribute("value", id);
				    form.appendChild(hiddenField);
			    }
			    
			    document.body.appendChild(form);
			    form.submit();
			}
			
		}
		
	</script>

</head>
<body>
<%
	Object admin = request.getSession().getAttribute("admin");
	%>
	<div id="menu-wrapper">
		<div id="menu">
			<ul>
				<li><a href="index.jsp">Homepage</a></li>
				<li><a href="collaboration.jsp">Collaborations</a></li>
				<li><a href="friends.jsp">Friends</a></li>
				<li><a href="edit.jsp">Edit Profile</a></li>
				<li><a href="logout.jsp">Logout</a></li>
				
				<%if (admin == null || !(Boolean) admin) {
				%>	
				<li><a href="newskillreq.jsp">Request Skill</a></li>
				<%}  else {
				%>	
				<li class="current_page_item"><a href="newskill.jsp">Create Skill</a></li>
				<%}%>
			</ul>
		</div>
		<!-- end #menu -->
	</div>

<div id="wrapper">
	<div id="header-wrapper">
		<div id="header">
			<div id="logo">
				<h1><a href="#">SWIM</a></h1>
				<p>"A social network for friends needing or offering help"</p>
			</div>
		</div>
	</div>
	<!-- end #header -->
	<div id="page">
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
					<div class="post">
						<h2 class="title">New Skill</h2>
						
						<div class="entry">
							<br/>Name: <br/>
							<textarea id="name" name="name" maxLenght="45" value="" maxlength="255" cols="45" rows="1"></textarea>
							<br/>
							<%SkillRequest s = (SkillRequest) request.getAttribute("nsreq");
								%>
								Description:<br/>
							<textarea id="description" name="description" value="" maxlength="255" cols="45" rows="5"><% 
								if(s!=null) {
									out.print(s.getDescSkill());
							} %></textarea>
							<br/><input type="button" value="Go back" onClick="window.location='index.jsp'"/>
							<input type="button" value="Add New Skill" onClick="checkNotEmpty(document.getElementById('description'),document.getElementById('name'), '<%if(s!=null) {out.print(s.getId());}%>');"/>
						</div>
					</div>
					<div style="clear: both;">&nbsp;</div>
				</div>
				<!-- end #content -->
				<div id="sidebar">
					<ul>
						<li>
						</li>
						
					</ul>
				</div>
				<!-- end #sidebar -->
				<div style="clear: both;">&nbsp;</div>
			</div>
		</div>
	</div>
	<!-- end #page -->
</div>
<div id="footer">
	<p></p>
</div>
<!-- end #footer -->
</body>
</html>